home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 142 / Gekkan Dennou Club - 2000.3 Vol. 142 (Japan).7z / Gekkan Dennou Club - 2000.3 Vol. 142 (Japan) (Track 1).bin / tools / s_tool / str_.c < prev    next >
Text File  |  1997-10-08  |  11KB  |  518 lines

  1. #include    "JX250.H"
  2. #include    <sys\iocs.h>
  3. #include    <sys\dos.h>
  4. #include    <sys\scsi.h>
  5. #include    <stdlib.h>
  6. #include    <math.h>
  7. #include    <_tnb.c>
  8.  
  9.  
  10. /******************************************************
  11.     数値プリント(ito3a付き)
  12. ******************************************************/
  13. void    p_12_ito3a(x,y,d)
  14. int    x,y,d;
  15. {
  16. char    buf[16];
  17. ito3a(d,buf);
  18. p_12W(x,y,buf);
  19. }
  20. /******************************************************
  21.     数値プリント(ito4a付き)
  22. ******************************************************/
  23. void    p_12_ito4a(x,y,d)
  24. int    x,y,d;
  25. {
  26. char    buf[16];
  27. ito4a(d,buf);
  28. p_12W(x,y,buf);
  29. }
  30. /******************************************************
  31.     数値プリント(sprintf付き)
  32. ******************************************************/
  33. void    p_12_sprintf(x,y,str,d1,d2,d3)
  34. int    x,y,d1,d2,d3;
  35. UNchar    *str;
  36. {
  37. char    buf[100];
  38. sprintf(buf,str,d1,d2,d3);
  39. p_12W(x,y,buf);
  40. }
  41. /******************************************************
  42.     数値プリント(sprintf付き)
  43. ******************************************************/
  44. void    p_12_sprintf_double(x,y,str,d1,d2)
  45. int    x,y;
  46. double    d1,d2;
  47. UNchar    *str;
  48. {
  49. char    buf[100];
  50. sprintf(buf,str,d1,d2);
  51. p_12W(x,y,buf);
  52. }
  53. /*****************************************************
  54.         背景(白)付き12dot 文字列表示
  55. *****************************************************/
  56. int    p_12W(x,y,st)
  57. int    x,y;
  58. UNchar    *st;
  59. {
  60. int    i,l;
  61. struct _fillptr PP;
  62. l=jstrlen_(st);
  63. PP.x1=x;
  64. PP.y1=y;
  65. PP.x2=x+l*6-1;
  66. PP.y2=y+12-1;
  67. PP.color=PalTable[15];
  68. _iocs_fill(&PP);
  69. return( p_12H(x,y,st) );
  70. }
  71. /*****************************************************
  72.                12ドット文プリント
  73. *****************************************************/
  74. int    p_12H(x,y,st)
  75. int    x,y;
  76. UNchar    *st;
  77. {
  78. int    i,l,o;
  79. int    ssp;
  80. struct FNTBUF    FB;
  81. ssp=_iocs_b_super(0);
  82. GGCHAR_COLOR1=RGB(1,1,1);
  83. while( l=*(st++) ){
  84.     if ( ZenChk(l) )
  85.         l=(l*0x100)+(*st++);
  86.     FNTGET12(l,&FB);
  87.     GGCHAR_S(VADDS(0,x,y),&FB);
  88.     x+=FB.xl;
  89. }
  90. if ( ssp>=0 )
  91.     _iocs_b_super(ssp);
  92. return(0);
  93. }
  94. /*****************************************************
  95.                影付き16ドット文プリント
  96. *****************************************************/
  97. int    p_16K(x,y,st)
  98. int    x,y;
  99. UNchar    *st;
  100. {
  101. int    i,l,o;
  102. int    ssp;
  103. struct _fntbuf    FB;
  104. ssp=_iocs_b_super(0);
  105. while( l=*(st++) ){
  106.     if ( ZenChk(l) )
  107.         l=(l*0x100)+(*st++);
  108.     _iocs_fntget(8,l,&FB);
  109.     GGCHAR_COLOR1=RGB(1,1,1);
  110.     GGCHAR_S(VADDS(0,x+1,y+1),&FB);
  111.     GGCHAR_COLOR1=RGB(31,31,31);
  112.     GGCHAR_S(VADDS(0,x,y),&FB);
  113.     x+=FB.xl;
  114. }
  115. if ( ssp>=0 )
  116.     _iocs_b_super(ssp);
  117. GGCHAR_COLOR1=RGB(1,1,1);
  118. return(0);
  119. }
  120. /*****************************************************
  121.                影付き12ドット文プリント
  122. *****************************************************/
  123. int    p_12K(x,y,st)
  124. int    x,y;
  125. UNchar    *st;
  126. {
  127. int    i,l,o;
  128. int    ssp;
  129. struct FNTBUF    FB;
  130. ssp=_iocs_b_super(0);
  131. GGCHAR_COLOR1=RGB(1,1,1);
  132. while( l=*(st++) ){
  133.     if ( ZenChk(l) )
  134.         l=(l*0x100)+(*st++);
  135.     FNTGET12(l,&FB);
  136.     GGCHAR_COLOR1=RGB(1,1,1);
  137.     GGCHAR_S(VADDS(0,x+1,y+1),&FB);
  138.     GGCHAR_COLOR1=RGB(31,31,31);
  139.     GGCHAR_S(VADDS(0,x,y),&FB);
  140.     x+=FB.xl;
  141. }
  142. if ( ssp>=0 )
  143.     _iocs_b_super(ssp);
  144. return(0);
  145. }
  146. /*****************************************************
  147.                12ドット文テキストプリント
  148. *****************************************************/
  149. int    text_12H(x,y,st)
  150. int    x,y;
  151. UNchar    *st;
  152. {
  153. int    i,l,o;
  154. int    ssp;
  155. struct FNTBUF    FB;
  156. ssp=_iocs_b_super(0);
  157. o=*(UNshort*)0xe8002a;
  158. //*(UNshort*)0xe8002a=0x1F0;
  159. *(UNshort*)0xe8002a=0x00;
  160. while( l=*(st++) ){
  161.     if ( ZenChk(l) )
  162.         l=(l*0x100)+(*st++);
  163.     FNTGET12(l,&FB);
  164.     if ( FB.xl==6 )
  165.         TXHMOJI_S(x,y,&FB);
  166.     else    TXZMOJI_S(x,y,&FB);
  167.     x+=FB.xl;
  168. }
  169. *(UNshort*)0xe8002a=o;
  170. if ( ssp>=0 )
  171.     _iocs_b_super(ssp);
  172. return(0);
  173. }
  174. /*************************************************
  175.               intを2文字列に
  176. *************************************************/
  177. void    ito2a(i,st)
  178. int    i;
  179. UNchar    *st;
  180. {
  181. int    l,k;
  182. k=DIVU(i,10);    *st++=( k )?k+'0':' ';
  183.         *st++=MODU(i,10)+'0';
  184.         *st  =0;
  185. }
  186. /*************************************************
  187.               intを3文字列に
  188. *************************************************/
  189. void    ito3a(i,st)
  190. int    i;
  191. UNchar    *st;
  192. {
  193. int    l,k;
  194. l=DIVU(i,100);            *st++=( l )?l+'0':' ';
  195. k=DIVU(i,10);k-=MULU(l,10);    *st++=( k )?k+'0':( l )?'0':' ';
  196.                 *st++=MODU(i,10)+'0';
  197.                 *st  =0;
  198. }
  199. /*************************************************
  200.               intを4文字列に
  201. *************************************************/
  202. void    ito4a(i,st)
  203. int    i;
  204. UNchar    *st;
  205. {
  206. int    j,l,k;
  207. j=DIVU(i,1000);            *st++=( j )?j+'0':' ';
  208. l=DIVU(i,100); l=MODU(l,10);    *st++=( l )?l+'0':( j )?'0':' ';
  209. k=DIVU(i,10); k=MODU(k,10);    *st++=( k )?k+'0':( l )?'0':( j )?'0':' ';
  210.                 *st++=MODU(i,10)+'0';
  211.                 *st  =0;
  212. }
  213. /*************************************************
  214.               intを5文字列に
  215. *************************************************/
  216. void    ito5a(i,st)
  217. int    i;
  218. UNchar    *st;
  219. {
  220. int    a,j,l,k;
  221. a=DIVU(i,10000);        *st++=( a )?a+'0':' ';
  222. j=DIVU(i,1000);j=MODU(j,10);    *st++=( j )?j+'0':( a )?'0':' ';
  223. l=DIVU(i,100); l=MODU(l,10);    *st++=( l )?l+'0':( j )?'0':( a )?'0':' ';
  224. k=DIVU(i,10); k=MODU(k,10);    *st++=( k )?k+'0':( l )?'0':( j )?'0':( a )?'0':' ';
  225.                 *st++=MODU(i,10)+'0';
  226.                 *st  =0;
  227. }
  228. /*************************************************
  229.              漢字を含む文字列の複製
  230. *************************************************/
  231. char    *jstrcpy(sou,des)
  232. UNchar    *sou,*des;
  233. {
  234. UNchar    c;
  235. UNchar    *r=sou;
  236. while( c=(*(sou++)=*(des++)) )
  237.     if ( ZenChk(c) )
  238.         *(sou++)=*(des++);
  239. return(r);
  240. }
  241. /*************************************************
  242.             漢字を含む文字列の連結
  243. *************************************************/
  244. char    *jstrcat(sou,des)
  245. UNchar    *sou,*des;
  246. {
  247. UNchar    c;
  248. UNchar    *r=sou;
  249. while( c=*(sou) ){
  250.     sou++;
  251.     if ( ZenChk(c) )
  252.         sou++;
  253. }
  254. while( c=(*(sou++)=*(des++)) )
  255.     if ( ZenChk(c) )
  256.         *(sou++)=*(des++);
  257. return(r);
  258. }
  259. /*************************************************
  260.               漢字を含む文字列長(byte)
  261.        全角は2文字分
  262. *************************************************/
  263. int    jstrlen(st)
  264. UNchar    *st;
  265. {
  266. int    l,c;
  267. l=0;
  268. while( c=*(st++) ){
  269.     l++;
  270.     if ( ZenChk(c) ){
  271.         l++;    st++;
  272.     }
  273. }
  274. return(l);
  275. }
  276. /*************************************************
  277.               漢字を含む文字列長(文字幅)
  278.        全角は2文字分
  279. *************************************************/
  280. int    jstrlen_(st)
  281. UNchar    *st;
  282. {
  283. int    l,c;
  284. l=0;
  285. while( c=*(st++) ){
  286.     l++;
  287.     if ( ZenChk(c) ){
  288.         if ( c>0x80 && c<0xF0 )
  289.             l++;
  290.         st++;
  291.     }
  292. }
  293. return(l);
  294. }
  295. /*************************************************
  296.             漢字を含む文字列長(文字幅,TAB考慮)
  297.        全角は2文字分
  298. *************************************************/
  299. int    jstrlen_tb(st)
  300. UNchar    *st;
  301. {
  302. int    l,c;
  303. l=0;
  304. while( c=*(st++) ){
  305.     if ( c==0x0d || c==0x0a || c==0x1a )
  306.         break;
  307.     if ( c=='\t' ){
  308.         do{
  309.             l++;
  310.         } while ( l % 8 );
  311.         continue;
  312.     }
  313.     l++;
  314.     if ( ZenChk(c) ){
  315.         if ( c>0x80 && c<0xF0 )
  316.             l++;
  317.         st++;
  318.     }
  319. }
  320. return(l);
  321. }
  322. /*************************************************
  323.  漢字を含む文字列の半角英字小文字を大文字にします
  324.        全角は2文字分
  325. *************************************************/
  326. int    jstrupr(st)
  327. UNchar    *st;
  328. {
  329. int    c;
  330. UNchar    *r=st;
  331. while( c=*st ){
  332.     if ( ZenChk(c) )
  333.         st++;
  334.     elif ( c>=0x61 && c<=0x7A )
  335.         *st=c-0x20;
  336.     st++;
  337. }
  338. return(r);
  339. }
  340. /*************************************************
  341.  漢字を含む文字列の比較をします
  342. (半角英字は大文字小文字区別されません))
  343. *************************************************/
  344. int    jstrcmpi(st1,st2)
  345. UNchar    *st1,*st2;
  346. {
  347. int    c,c1,c2;
  348. do {
  349.     c1=*st1++;
  350.     if ( ZenChk(c1) ){
  351.         /*[1]は全角*/
  352.         c2=*st2++;
  353.         if ( c1<c2 )    return(-1);
  354.         if ( c1>c2 )    return(1);
  355.         if ( ZenChk(c2)==0 )
  356.             return(1);    /*[2]は全角じゃない*/
  357.         c=*st1++;
  358.         c2=*st2++;
  359.         if ( c<c2 )    return(-1);
  360.         if ( c>c2 )    return(1);
  361.         c1=c1*0x100+c;
  362.     } else {
  363.         /*[1]は半角*/
  364.         c2=*st2++;
  365.         if ( ZenChk(c2)!=0 )
  366.             return(-1);    /*[2]は全角だ*/
  367.         if ( c1>='A' && c1<='Z' ) c1|=0x20;
  368.         if ( c2>='A' && c2<='Z' ) c2|=0x20;
  369.         if ( c1<c2 )    return(-1);
  370.         if ( c1>c2 )    return(1);
  371.     }
  372. } while( c1!=0 );
  373. return(0);
  374. }
  375. /**************************************************
  376.     全角チェック)
  377. [戻り値] 0 : 半角
  378.      1 : 全角
  379. **************************************************/
  380. int    ZenChk(c)
  381. int    c;
  382. {
  383. return( (c>=0x80 && c<=0x9f) || c>=0xE0 );
  384. }
  385. /*************************************************
  386.         ダイアログ表示
  387. [in]    *s1,*s2,*s3 表示文字列
  388.     md=-1; 表示を消す
  389.     md= 0; 待ちなし
  390.     md= 1; 確認
  391.     md= 2; 選択
  392. [out] md==2 の場合のみ。
  393.      0 ; 選択
  394.     -1 ; 中止
  395. *************************************************/
  396. int    Dialog(s1,s2,s3,md)
  397. UNchar    *s1,*s2,*s3;
  398. int    md;
  399. {
  400. int    i,j,b,r;
  401. int    xx,yy;
  402. int    ssp;
  403. extern    UNchar    diabak[165*205*2];    // ダイアログ用のバッファ
  404. struct _fillptr PP;
  405. struct _getptr GP;
  406. GP.buf_start=&diabak[0];
  407. GP.buf_end=&diabak[165*205*2-1];
  408. PP.x1 = GP.x1 = 2*16;
  409. PP.y1 = GP.y1 = 10*16;
  410. PP.x2 = GP.x2 = GP.x1+12*16+8;
  411. PP.y2 = GP.y2 = GP.y1+10*16;
  412. //--
  413. if ( md<0 ){
  414.     // 消す(前に「待ちなし」を実行していること)
  415.     _iocs_putgrm( &GP );
  416.     return(0);
  417. }
  418. //-- 記憶
  419. _iocs_getgrm( &GP );
  420. //-- ベタ書く
  421. PP.color=PalTable[14];
  422. _iocs_fill(&PP);
  423. //-- 枠(白)書く
  424. PP.x1=2*16;
  425. PP.y1=10*16;
  426. PP.x2=PP.x1+1;
  427. PP.y2=PP.y1+10*16;
  428. PP.color=PalTable[15];
  429. _iocs_fill(&PP);
  430. PP.x2=PP.x1+12*16+8;
  431. PP.y2=PP.y1+1;
  432. _iocs_fill(&PP);
  433. //-- 枠(影)書く
  434. PP.x1=2*16+12*16+8-1;
  435. PP.y1=10*16+1;
  436. PP.x2=PP.x1+1;
  437. PP.y2=PP.y1+10*16-1;
  438. PP.color=PalTable[10];
  439. _iocs_fill(&PP);
  440. PP.x1=2*16+1;
  441. PP.y1=10*16+10*16-1;
  442. PP.x2=PP.x1+12*16+8-1;
  443. PP.y2=PP.y1+1;
  444. _iocs_fill(&PP);
  445. //--
  446. if ( s1!=0 )
  447.     p_12H(4*16,11*16,s1);
  448. if ( s2!=0 )
  449.     p_12H(4*16,13*16,s2);
  450. if ( s3!=0 )
  451.     p_12H(4*16,15*16,s3);
  452. if ( md==0 )
  453.     return(0);
  454. while( MS_LSW()!=0 || MS_RSW()!=0 );
  455. ssp=_iocs_b_super(0);
  456. if ( md==1 ){
  457.     // 確認のみ
  458.     GGSP16_64_S(TADDS(12,17),0x48);
  459.     GGSP16_64_S(TADDS(13,17),0x49);
  460.     GGSP16_64_S(TADDS(12,18),0x50);
  461.     GGSP16_64_S(TADDS(13,18),0x51);
  462.     /*
  463.     PP.x=12*16;
  464.     PP.y=17*16;
  465.     PP.x1=32*1;
  466.     PP.y1=32*1;
  467.     PP.vram_page=0x8003;
  468.     PP.fill_patn=0x0000;
  469.     _iocs_txfill(&PP);
  470.     */
  471. } else {
  472.     // 選択
  473.     GGSP16_64_S(TADDS(10,17),0x48);
  474.     GGSP16_64_S(TADDS(11,17),0x49);
  475.     GGSP16_64_S(TADDS(10,18),0x50);
  476.     GGSP16_64_S(TADDS(11,18),0x51);
  477.     GGSP16_64_S(TADDS(12,17),0x4a);
  478.     GGSP16_64_S(TADDS(13,17),0x4b);
  479.     GGSP16_64_S(TADDS(12,18),0x52);
  480.     GGSP16_64_S(TADDS(13,18),0x53);
  481.     /*
  482.     PP.x=10*16;
  483.     PP.y=17*16;
  484.     PP.x1=32*2;
  485.     PP.y1=32*1;
  486.     PP.vram_page=0x8003;
  487.     PP.fill_patn=0x0000;
  488.     _iocs_txfill(&PP);
  489.     */
  490. }
  491. if ( ssp>0 )
  492.     _iocs_b_super(ssp);
  493. //_iocs_sp_on();
  494. MsPat(1);
  495. for(;;){
  496.     do {
  497.         yy=( i=_iocs_ms_curgt() )&0xFFFF;
  498.         xx=i>>16;
  499.         //_iocs_sp_regst(0,bit(31),xx+16  ,yy+16  ,1,1);
  500.     } while( MS_LSW()==0 && (b=MS_RSW())==0 );
  501.     if ( yy<17*16 || yy>=19*16 )
  502.         continue;
  503.     if ( xx>=12*16 && xx<14*16 ){
  504.         if ( sxbotton(12*16,17*16,14*16-1,19*16-1,1)==0 ){
  505.             r=-1;
  506.             break;
  507.         }
  508.     } elif ( md==2 && xx>=10*16 && xx<12*16 ){
  509.         if ( sxbotton(10*16,17*16,12*16-1,19*16-1,1)==0 ){
  510.             r=0;
  511.             break;
  512.         }
  513.     }
  514. }
  515. _iocs_putgrm( &GP );
  516. return(r);
  517. }
  518.